<?php
namespace app\admin\controller;

use think\Controller;
use think\Model;
use think\Request;
use think\Db;

class Index extends Controller
{
    public function index()
	{
		 $this->redirect('/admin/Login');
	}
	
	public function saveuser()
	{
		//实例化数据库
		$user = Model('User');
	    
		$cz = $user -> where(['u_phone' => $_POST['phone']])->find();
		
		if(!$cz){
			
			$data['u_name'] =$_POST['name'];
			$data['u_phone'] = $_POST['phone'];
			$data['u_city'] = $_POST['city'];
			$data['u_address'] = $_POST['address'];
			$data['u_remark'] = $_POST['remark'];
			$data['addtime'] = time();
			$data['u_atpid'] = 'sjhk'.time().rand(0000,9999);
		
            $user -> insert($data);	
		}else{
			
			echo json_encode(['status' => 0, 'msg' => '您已经提交信息,请进行下一步']);
		
		}
		//$res = Db::table('user') -> insert($data);
	}
	
	public function addstatus()
	{
		
		//实例化数据库
		$user = Model('User');
		
		$phone = $_POST['phone'];
		file_put_contents('D:\product\blackcard\Application\admin\1.php',var_export($phone,TRUE));
	    //保存用户的支付方式
		$data['u_status'] = '1';
		
		$cz = $user -> where(['u_phone' => $_POST['phone']])->update($data);
		
	}
}
